package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import models.Repair;
import models.Repair;
import vos.RepairSeachVo;
import vos.RepairVo;

public interface RepairMapper {
	/**
	 * 统计检修
	 *
	 * @Title: countRepair 
	 * @return
	 * @return: long
	 */
	long countRepair();
	/**
	 * 获取检修列表
	 *
	 * @Title: listRepair 
	 * @param vo
	 * @return
	 * @return: List<RegionVo>
	 */
	List<Repair> listRepair(RepairSeachVo vo);
	/**
	 * 批量删除检修
	 *
	 * @Title: betchDel 
	 * @param map
	 * @return: void
	 */
	void betchDel(Map<String, List<String>> map);
	/**
	 * 根据id删除检修
	 *
	 * @Title: delRepair 
	 * @param id
	 * @return: void
	 */
	@Delete("delete from "
			+ Repair.TABLE_NAME
			+" where id=#{id}")
	void delRepair(String id);
	/**
	 * 根据id判断是否存在该检修
	 *
	 * @Title: checkCode 
	 * @param levelid
	 * @return
	 * @return: String
	 */
	@Select("select 1 from "
			+ Repair.TABLE_NAME
			+" where id=#{id}")
	String checkCode(String id);
	/**
	 * 根据id获取检修信息
	 *
	 * @Title: getById 
	 * @param levelid 检修id
	 * @return
	 * @return: Repair
	 */
	@Select("select * from device_repair_view"
			+" where id=#{id}")
	RepairVo getById(Long id);
	/**
	 * 保存检修信息
	 *
	 * @Title: saveRepair 
	 * @param device
	 * @return: void
	 */
	@Insert("insert into "
			+ Repair.TABLE_NAME
			+" (deviceid,title,repairtime,cost,invitation,createtime,createname,remark) values"
			+ "(#{deviceid},#{title},#{repairtime},#{cost},#{invitation},#{createtime},#{createname},#{remark})")
	void saveRepair(Repair repair);
	/**
	 * 更新检修信息
	 *
	 * @Title: updateRepair 
	 * @param device
	 * @return: void
	 */
	@Update("update "
			+ Repair.TABLE_NAME
			+" set deviceid=#{deviceid},title=#{title},cost=#{cost},invitation=#{invitation},"
			+ "repairtime=#{repairtime},modifyname=#{modifyname},modifytime=#{modifytime},remark=#{remark}"
			+ " where id=#{id}")
	void updateRepair(Repair repair);
	/**
	 * 导出为excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<Repair>
	 */
	List<RepairVo> exportXls(RepairSeachVo vo);
}
